package com.zp.mvppractice.mvp2;

import android.os.Bundle;

/**
 * Created by izp on 2017/7/10.
 */

public abstract class DataBindActivity<D extends Delegate> extends PresentActivity<D>{
    protected DataBinder binder;

    /**
     * @return 需要继承者 通过构造器构建DataBinder的实现类
     */
    public abstract DataBinder getDataBinder();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binder = getDataBinder();
    }

    public <M extends DataModel> void notifyModelChanged(M data) {
        if (binder != null)
            binder.viewBindModel(viewDelegate, data);
    }
}
